<?php
if (!defined("DNREAD")) exit();
global $db,$basepref,$api,$setting;
$bc = '';
$bs = array(
            'col' => array('lang'=>'all_col',
                           'form'=>'text',
                           'value'=>1,
                           'default'=>1),
            'date' => array('lang'=>'all_data',
                            'form'=>'checkbox',
                            'value'=>'yes',
                            'default'=>'yes'),
            'short' => array('lang'=>'input_text',
                             'form'=>'checkbox',
                             'value'=>'yes',
                             'default'=>'yes'),
            'image' => array('lang'=>'all_image',
                             'form'=>'checkbox',
                             'value'=>'yes',
                             'default'=>'yes'),
            'sort' => array('lang'=>'all_sorting',
                            'form'=>'select',
                            'value'=>array('newsid'=>'ID','title'=>'all_name','public'=>'all_data','hits'=>'all_hits','comments'=>'menu_comment'),
                            'default'=>'newsid'),
            'order' => array('lang'=>'all_sorting',
                             'form'=>'select',
                             'value'=>array('desc'=>'all_desc','asc'=>'all_acs'),
                             'default'=>'desc'),
            'autoslide' => array('lang'=>'Auto Slide',
                                 'form'=>'checkbox',
                                 'value'=>'yes',
                                 'default'=>'yes'),
            'autoslideinterval' => array('lang'=>'Auto Slide Interval',
                                         'form'=>'text',
                                         'value'=>3500,
                                         'default'=>3500),
            'dynamictabsalign' => array('lang'=>'Tabs Align',
                                        'form'=>'select',
                                        'value'=>array('left'=>'left','right'=>'right'),
                                        'default'=>'left'),
            'dynamictabsposition' => array('lang'=>'Tabs Position',
                                           'form'=>'select',
                                           'value'=>array('bottom'=>'bottom','top'=>'top'),
                                           'default'=>'bottom'),
            'imp' => array('lang'=>'all_important',
                           'form'=>'checkbox',
                           'value'=>'yes',
                           'default'=>'no')
           );
if (defined('SETTING')) {
    return $bs;
}
if (isset($setting['bsarray']) && is_array($setting['bsarray'])) {
    $bs = $setting['bsarray'];
}
$inq = $db->query("SELECT newsid,public,cpu,title,textshort,image_thumb,image_align FROM ".$basepref."_news WHERE act='yes' AND (stpublic=0 OR stpublic<'".NEWTIME."') AND (unpublic=0 OR unpublic>'".NEWTIME."') ".(($bs['imp'] == 'yes') ? 'AND imp = 1 ' : '')."ORDER BY ".$bs['sort']." ".$bs['order']." LIMIT ".$bs['col']);
if ($db->numrows($inq) > 0) {
    $bc.= '<script type="text/javascript" src="'.$setting['site_url'].'/temp/'.$setting['site_temp'].'/javascript/jquery.easing.js"></script>
           <script type="text/javascript" src="'.$setting['site_url'].'/temp/'.$setting['site_temp'].'/javascript/jquery.coda.slider.js"></script>
	       <script type="text/javascript">
               $().ready(function() {
                   var sliderwidth = $("#coda-slider-news").width();
                   $("#coda-slider-news, #coda-slider-news .panel").width(sliderwidth);
		    	   $("#coda-slider-news").codaSlider({
                       autoSlide:'.(($bs['autoslide'] == 'yes') ? 'true' : 'false').',
                       autoHeightEaseFunction: "easeInOutExpo",
                       autoSlideInterval:'.$bs['autoslideinterval'].',
                       autoSlideStopWhenClicked:true,
                       dynamicArrows:false,
                       dynamicTabs:true,
                       dynamicTabsAlign:"'.$bs['dynamictabsalign'].'",
		               dynamicTabsPosition:"'.$bs['dynamictabsposition'].'"
                    });
		    	});
		     </script>';
    $bc.= '<div class="coda-slider-block"><div class="coda-slider-wrapper">'
	      .'<div class="coda-slider preload" id="coda-slider-news">';
    $c = 1;
    while ($item = $db->fetchrow($inq)) {
        $bc.= '<div class="panel"><div class="panel-wrapper">';
        $blockcpu = ($siteglobal['seourl'] == 1 && $item['cpu']) ? '&amp;cpu='.$item['cpu'] : '';
        $date = $api->sitetime($item['public'],0);
        $bc.= '<span class="pagenator">'.$c.'</span>';
        $flimg = ($item['image_align'] == 'left') ? 'imgleft' : 'imgright';
        if ($bs['image'] == 'yes') {
            $bc.= ($item['image_thumb']) ? '<div class="thumb '.$flimg.'"><img src="'.$setting['site_url'].'/'.$item['image_thumb'].'" alt="" /></div>' : '';
        }
        $bc.= '<h3><a href="'.$setting['site_url'].'/index.php?dn=news&amp;to=art&amp;id='.$item['newsid'].$blockcpu.'">'.$item['title'].'</a></h3>';
        if ($bs['short'] == 'yes') {
            $bc.= '<p>'.$item['textshort'].'</p>';
        }
        $bc.= '</div></div>';
        $c++;
    }
    $bc.= '</div>'
          .'</div></div>';
}
return $api->siteuni($bc);
?>
